package net.zjitc.servlet;

import net.zjitc.domain.Product;
import net.zjitc.service.ProductService;
import net.zjitc.service.impl.ProductServiceImpl;
import org.apache.commons.beanutils.BeanUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;

/**
 * @version 1.0
 * @autho 赵静静
 * @date 2018/10/18 11:52
 */
@WebServlet(name = "EditServlet",urlPatterns = "/editServlet")
public class EditServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       request.setCharacterEncoding("UTF-8");
        String pid = request.getParameter("pid");
        Product p = new Product();
        try {
            BeanUtils.populate(p,request.getParameterMap());
            ProductService service = new ProductServiceImpl();
            //....
        } catch (Exception e) {
            e.printStackTrace();
        }
        response.sendRedirect(getServletContext().getContextPath()+"/findAllServlet");
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
